#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include <string>
class Solution {
public:
    int StrToInt(string str)
    {
        int isPN = 1, i = 0, ans = 0;
        while (str[i] != '\0')
        {
            if (isalpha(str[i]))
            {
                return 0;
            }
            if (str[i] == '+' || str[i] == '-')
            {
                isPN = (str[i] == '+') ? 1 : -1;
            }
            if (isdigit(str[i]))
            {
                ans = ans * 10 + str[i] - '0';
            }
            i++;
        }
        return isPN * ans;
    }
};